/*
 * $Id: ArgumentException.java 4 2007-12-20 21:20:26Z aaron.day $
 */
package org.crazydays.text;


import java.io.Serializable;

/**
 * ArgumentException
 */
public class ArgumentException
	extends Exception
	implements Serializable
{
	/** serial version uid */
	public final static long serialVersionUID = "$Id: ArgumentException.java 4 2007-12-20 21:20:26Z aaron.day $".hashCode();

	/** argument */
	protected Argument argument;

	/**
	 * ArgumentException constructor.
	 */
	public ArgumentException()
	{
	}

	/**
	 * ArgumentException constructor.
	 * 
	 * @param message Message
	 */
	public ArgumentException(String message)
	{
		super(message);
	}

	/**
	 * ArgumentException constructor.
	 * 
	 * @param cause Cause
	 */
	public ArgumentException(Throwable cause)
	{
		super(cause);
	}

	/**
	 * ArgumentException constructor.
	 * 
	 * @param message Message
	 * @param cause Cause
	 */
	public ArgumentException(String message, Throwable cause)
	{
		super(message, cause);
	}

	/**
	 * Set argument.
	 * 
	 * @param argument.
	 * @return ArgumentException
	 */
	public ArgumentException setArgument(Argument argument)
	{
		this.argument = argument;

		return this;
	}

	/**
	 * Get argument.
	 * 
	 * @return Argument
	 */
	public Argument getArgument()
	{
		return argument;
	}

	/**
	 * To String.
	 *
	 * @return String
	 * @see Object#toString()
	 */
	public String toString()
	{
		StringBuffer buffer = new StringBuffer();

		buffer.append(super.toString());

		Argument argument = getArgument();
		if (argument != null) {
			buffer.append(" Argument: ");
			buffer.append(argument);
		}

		return buffer.toString();
	}
}
